package hashmap;


import test.Student;

import java.util.Comparator;
import java.util.TreeMap;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : HashMapDemo1
 * @Author : 54061
 * @Date: 2022/2/10 15:43
 */
public class HashMapDemo1 {
    public static void main(String[] args) {
        //创建集合对象
        //TreeMap<Student,String> tm = new TreeMap<>();
        TreeMap<Student,String> tm = new TreeMap<>(new Comparator<Student>(){
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge() - o1.getAge();

            }
        });
        //添加元素

        tm.put(new Student("张三",18),"男");
        tm.put(new Student("李四",16),"女");
        System.out.println("tm = " + tm);

    }
}
